//
//  RootViewController.m
//  Morning
//
//  Created by dllo on 15/12/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
//    // 加载小菊花
//    UIActivityIndicatorView *actlndicatorV = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
////    actlndicatorV.center = CGPointMake(self.view.center.x, self.view.center.y);
//    actlndicatorV.frame = CGRectMake(50, 100, 160, 160);
//    actlndicatorV.backgroundColor = [UIColor blackColor];
//    actlndicatorV.color = [UIColor yellowColor];
//    actlndicatorV.layer.cornerRadius = 80;
//    actlndicatorV.layer.masksToBounds = YES;
//    [self.view addSubview:actlndicatorV];
//    [actlndicatorV release];
//    [actlndicatorV startAnimating];
////
//    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(50, 300, 160, 160)];
//    imageV.image = [UIImage imageNamed:@"image4.jpg"];
//    imageV.layer.cornerRadius = 20;
//    imageV.layer.masksToBounds = YES;
//    [self.view addSubview:imageV];
//    [imageV release];
//    
//    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.backgroundColor = [UIColor yellowColor];
//    [button setTitle:@"点我" forState:UIControlStateNormal];
//    button.frame = CGRectMake(50, 500, 100, 100);
//    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchDragInside];
//    [self.view addSubview:button];
    
    // 开关
    UISwitch *swich = [[UISwitch alloc] initWithFrame:CGRectMake(60, 100, 30, 30)];
    swich.onTintColor = [UIColor yellowColor];
    swich.thumbTintColor = [UIColor blackColor];
    swich.tintColor = [UIColor blueColor];
    [swich addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:swich];
    

    
}

- (void)switchAction:(UISwitch *)sender
{
//    self.view.backgroundColor = [UIColor yellowColor];
    
    // 状态栏
    UIWindow *statusWindow = [[UIWindow alloc] initWithFrame:[UIApplication sharedApplication].statusBarFrame];
    [statusWindow setWindowLevel:UIWindowLevelStatusBar + 1];
    [statusWindow setBackgroundColor:[UIColor clearColor]];
    
    UILabel *statusLabel = [[UILabel alloc] initWithFrame:statusWindow.bounds];
    statusLabel.text = @"你打开了开关";
    statusLabel.textColor = [UIColor redColor];
    statusLabel.textAlignment = NSTextAlignmentCenter;
    statusLabel.backgroundColor = [UIColor blackColor];
    
    [statusWindow addSubview:statusLabel];
    [statusWindow makeKeyAndVisible];
    
    
    CATransition *transion = [CATransition animation];
    transion.type = @"push"; // 设置动画方式
    transion.subtype = @"fromRight"; // 设置动画从哪个方向开始
    [statusLabel.layer addAnimation:transion forKey:nil]; // 给Label.layer 添加动画// 设置延时效果
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [statusLabel removeFromSuperview];
    }); // 1.0秒后, 把label移出视图
    
    
    
}

- (void)buttonAction:(UIButton *)sender
{
    // 提示框
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"提示框" message:@"就是一个提示框" preferredStyle:UIAlertControllerStyleAlert];
    [alertC addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        
        textField.placeholder = @"用户";
        
    }];
    [alertC addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        
    }]];
    [self presentViewController:alertC animated:YES completion:^{
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
